package cn.wolfcode.luowowo.service.impl;

import cn.wolfcode.luowowo.domain.UserFavors;
import cn.wolfcode.luowowo.repository.UserFavorsRepository;
import cn.wolfcode.luowowo.service.IUserFavorsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserFavorsServiceImpl implements IUserFavorsService {
    @Autowired
    private UserFavorsRepository userFavorsRepository;

    @Override
    public void insert(UserFavors userFavors) {
        userFavorsRepository.save(userFavors);
    }

    @Override
    public void update(UserFavors userFavors) {
        userFavorsRepository.save(userFavors);
    }

    @Override
    public void delete(String id) {
        userFavorsRepository.deleteById(id);
    }

    @Override
    public UserFavors select(String id) {
        return userFavorsRepository.findById(id).get();
    }

    @Override
    public List<UserFavors> listAll() {
        return userFavorsRepository.findAll();
    }

    @Override
    public UserFavors selectByUserId(String id) {
        return userFavorsRepository.findByUserId(id);
    }
}
